package leetcode;

import javafx.util.Pair;

import java.util.Arrays;
import java.util.HashMap;

public class Test1 {

    public static void main(String[] args) {
        int[] ints = {3,2,4};
        Test1 test1 = new Test1();
        int[] ints1 = test1.twoSum(ints, 6);
        Arrays.stream(ints1).forEach(System.out::println);


    }

    public int[] twoSum(int[] nums, int target) {
        HashMap<Integer, Integer> hashMap = new HashMap<>();


        for(int i=0;i<nums.length;i++){
            if(hashMap.containsKey(nums[i])&&hashMap.get(nums[i])!=i){
                Integer integer = hashMap.get(nums[i]);
                int[] lala = {integer,i};
                return lala;
            }
            hashMap.put(target-nums[i],i);
        }
        return null;
    }

}
